
// Open MoneySpinner Suite v1
// An open source business management software system written in Java and MySQL
// Recommended IDE is NetBeans IDE 7.0.1
// Support Web Site: http://www.milliscript.com
//
// Copyright (C) 2014, Abiodun Aremu, Ibadan/NIGERIA.
// Open MoneySpinner Suite is distributed under the terms of the Apache License version 2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*
 * CashReport.java
 *
 * Created on Jan 25, 2011, 4:09:19 PM
 */

package openmoneyspinnersuite;

/**
 *
 * @author Abiodun Aremu
 */

import java.sql.*;
import javax.swing.*;

final class CashReport extends javax.swing.JInternalFrame {
    Object[][] tableObject=new Object[][]{};
    Systems systems=new Systems();
    PreparedStatement statement;
    Thread processThread=new Thread();
    Thread titleThread=new Thread();
    boolean[] cellEditable={};
    /** Creates new form ViewCredit */
     CashReport() {
        initComponents();
        /* Execute refresh thread */
        processThread=new Thread(new Runnable() {
            public void run() {
                disableControls();
                resetTable();
                resetCombo();
            }
        });
        titleThread=new Thread(new Runnable() {
            public void run() {
                while(processThread.isAlive())setProcessingTitle(titleThread);
                enableControls();
                System.out.println("viewStockReportThread stopped runing.");
            }
        });
        processThread.start();
        titleThread.start();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jRefreshButton = new javax.swing.JButton();
        jCancelButton = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jAccountTypeComboBox = new javax.swing.JComboBox();
        jMonthComboBox = new javax.swing.JComboBox();
        jYearComboBox = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();

        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(openmoneyspinnersuite.OpenMS_Finance_App.class).getContext().getResourceMap(CashReport.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setToolTipText(resourceMap.getString("Form.toolTipText")); // NOI18N
        setFrameIcon(resourceMap.getIcon("Form.frameIcon")); // NOI18N
        setName("Form"); // NOI18N
        setVisible(true);

        jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null}
            },
            new String [] {
                "Date", "Revenue", "Expense", "Hybrid", "Receivable", "Payable", "Cash Available", "Previous Cash Balance", "Cash Balance", "Unit", "Hybrid (Cr)", "Payable (Cr)", "Receivable (Cr)"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable1.setName("jTable1"); // NOI18N
        jScrollPane1.setViewportView(jTable1);
        jTable1.getColumnModel().getColumn(0).setPreferredWidth(40);
        jTable1.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("jTable1.columnModel.title0")); // NOI18N
        jTable1.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("jTable1.columnModel.title1")); // NOI18N
        jTable1.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("jTable1.columnModel.title7")); // NOI18N
        jTable1.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("jTable1.columnModel.title2")); // NOI18N
        jTable1.getColumnModel().getColumn(4).setHeaderValue(resourceMap.getString("jTable1.columnModel.title6")); // NOI18N
        jTable1.getColumnModel().getColumn(5).setHeaderValue(resourceMap.getString("jTable1.columnModel.title3")); // NOI18N
        jTable1.getColumnModel().getColumn(6).setHeaderValue(resourceMap.getString("jTable1.columnModel.title6")); // NOI18N
        jTable1.getColumnModel().getColumn(7).setHeaderValue(resourceMap.getString("jTable1.columnModel.title7")); // NOI18N
        jTable1.getColumnModel().getColumn(8).setHeaderValue(resourceMap.getString("jTable1.columnModel.title10")); // NOI18N
        jTable1.getColumnModel().getColumn(9).setHeaderValue(resourceMap.getString("jTable1.columnModel.title9")); // NOI18N
        jTable1.getColumnModel().getColumn(10).setHeaderValue(resourceMap.getString("jTable1.columnModel.title10")); // NOI18N
        jTable1.getColumnModel().getColumn(11).setHeaderValue(resourceMap.getString("jTable1.columnModel.title11")); // NOI18N
        jTable1.getColumnModel().getColumn(12).setHeaderValue(resourceMap.getString("jTable1.columnModel.title12")); // NOI18N

        jRefreshButton.setIcon(resourceMap.getIcon("jRefreshButton.icon")); // NOI18N
        jRefreshButton.setText(resourceMap.getString("jRefreshButton.text")); // NOI18N
        jRefreshButton.setName("jRefreshButton"); // NOI18N
        jRefreshButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRefreshButtonActionPerformed(evt);
            }
        });

        jCancelButton.setIcon(resourceMap.getIcon("jCancelButton.icon")); // NOI18N
        jCancelButton.setText(resourceMap.getString("jCancelButton.text")); // NOI18N
        jCancelButton.setName("jCancelButton"); // NOI18N
        jCancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCancelButtonActionPerformed(evt);
            }
        });

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jAccountTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Select --" }));
        jAccountTypeComboBox.setName("jAccountTypeComboBox"); // NOI18N
        jAccountTypeComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jAccountTypeComboBoxActionPerformed(evt);
            }
        });

        jMonthComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Month --" }));
        jMonthComboBox.setName("jMonthComboBox"); // NOI18N
        jMonthComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMonthComboBoxActionPerformed(evt);
            }
        });

        jYearComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Year --" }));
        jYearComboBox.setName("jYearComboBox"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 841, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(645, Short.MAX_VALUE)
                .addComponent(jRefreshButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jCancelButton)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jAccountTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(137, 137, 137)
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jMonthComboBox, 0, 159, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(jYearComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 431, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jMonthComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jYearComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(jAccountTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addGap(30, 30, 30)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jCancelButton, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jRefreshButton, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jRefreshButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRefreshButtonActionPerformed
//        if(jItemComboBox.getSelectedItem().toString().equalsIgnoreCase("-- Select "))
//        {
//            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"PLEASE SELECT AN ITEM CODE !","ERROR !",JOptionPane.ERROR_MESSAGE);
//            return;            
//        }
//        if(jMonthComboBox.getSelectedItem().toString().equalsIgnoreCase("-- Month --"))
//        {
//            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"PLEASE SELECT REPORT MONTH !","ERROR !",JOptionPane.ERROR_MESSAGE);
//            return;            
//        }
        if(jYearComboBox.getSelectedItem().toString().equalsIgnoreCase("-- Year --"))
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"PLEASE SELECT REPORT YEAR !","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;            
        }
        /* Execute refresh thread */
        processThread=new Thread(new Runnable() {
            public void run() {
                disableControls();
                if(jAccountTypeComboBox.getSelectedItem().toString().equalsIgnoreCase("-- Select --"))
                    refreshTable();
                else
                    refreshDetailTable();
            }
        });
        titleThread=new Thread(new Runnable() {
            public void run() {
                while(processThread.isAlive())setProcessingTitle(titleThread);
                enableControls();
                System.out.println("viewStockReportThread stopped runing.");
            }
        });
        processThread.start();
        titleThread.start();
    }//GEN-LAST:event_jRefreshButtonActionPerformed
     void reset()
    {
        /* Execute refresh thread */
        processThread=new Thread(new Runnable() {
            public void run() {
                disableControls();
                refreshTable();
                resetCombo();
            }
        });
        titleThread=new Thread(new Runnable() {
            public void run() {
                while(processThread.isAlive())setProcessingTitle(titleThread);
                enableControls();
                System.out.println("viewStockReportThread stopped runing.");
            }
        });
        processThread.start();
        titleThread.start();
    }
                                  
    public void resetYear()
    {
        String[] year=systems.getYears(1920);
        year[0]="-- Year --";
        jYearComboBox.setModel(new DefaultComboBoxModel(year));
    }
    public void resetMonth()
    {
        String[] month=systems.getMonthArray();
        month[0]="-- Month --";

        jMonthComboBox.setModel(new DefaultComboBoxModel(month));

    }
    private void setProcessingTitle(Thread thread)
    {
        try{
            this.setTitle("::. View Cash Report - Processing Request");
            thread.sleep(500);
            this.setTitle("::. View Cash Report - Processing Request.");
            thread.sleep(500);
            this.setTitle("::. View Cash Report - Processing Request..");
            thread.sleep(500);
            this.setTitle("::. View Cash Report - Processing Request...");
            thread.sleep(500);
        }catch(Exception e){System.out.println("Title thread"+e);}
    }
    private void jCancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCancelButtonActionPerformed
        
        if(processThread.isAlive())
        {
            try{
                processThread.stop();
                titleThread.stop();
                System.out.println("Threads successfully stopped.");
            }catch(Exception e){System.out.println("Thread stopping error: "+e);}
            this.setTitle("::. View Cash Report");
            enableControls();
        }
        else
        dispose();
    }//GEN-LAST:event_jCancelButtonActionPerformed

    private void jAccountTypeComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jAccountTypeComboBoxActionPerformed
        jAccountTypeComboBoxSelected();
    }//GEN-LAST:event_jAccountTypeComboBoxActionPerformed

private void jMonthComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMonthComboBoxActionPerformed

}//GEN-LAST:event_jMonthComboBoxActionPerformed
    private void jAccountTypeComboBoxSelected()
    {
        String accountName=jAccountTypeComboBox.getSelectedItem().toString();
        if(accountName.equals("-- Select --"))
        {
            resetAccountTypeCombo();
        }
    }
    void resetAccountTypeCombo()
    {
        String[] accountType={"","REVENUE","EXPENSE","HYBRID","RECEIVABLE","PAYABLE"};//systems.getTableDataArray(OpenMSApp.Database_A," vwTransferAccount",2);
        accountType[0]="-- Select --";
        jAccountTypeComboBox.setModel(new DefaultComboBoxModel(accountType));        
    }
    void resetCombo()
    {
        resetAccountTypeCombo();
        resetYear();
        resetMonth();
    }
    private void disableControls()
    {
        jRefreshButton.setEnabled(false);
        jAccountTypeComboBox.setEnabled(false);
    }
    private void enableControls()
    {
        jRefreshButton.setEnabled(true);
        jAccountTypeComboBox.setEnabled(true);
        this.setTitle("::. View Cash Report");
    }
    void resetTable()
    {
        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            tableObject,
            new String [] {
                "Date", "Revenue", "Expense", "Hybrid (Cr)", "Hybrid (Dr)", "Receivable (Cr)", "Receivable (Dr)", "Payable (Cr)", "Payable (Dr)", "Cash Available", "Previous Cash Balance", "Cash Balance", "Unit"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
    }
    void refreshDetailTable()
    {
        String[] reportDays={};int y=0;
        if(jMonthComboBox.getSelectedItem().toString().equalsIgnoreCase("-- Month --")==false){
            reportDays=systems.getDays(jMonthComboBox.getSelectedItem().toString());
        }
        else{
            reportDays=new String[]{"","01","02","03","04","05","06","07","08","09","10","11","12"};
            y=reportDays.length-1;
        }
        int x=1;
        //int y=reportDays.length-1;
        System.out.println("Length of report days= "+y);
        
        String accountType=jAccountTypeComboBox.getSelectedItem().toString();
        String[] tableHeader={},tableLead={"DATE"},tableTail={"TOTAL CR ||TOTAL DR","TOTAL CASH "+accountType};
        String[][] accountArray=systems.getColumn(OpenMSApp.Database_A, "Select * from account where cCategory='"+accountType+"'",1,2);

        tableHeader=systems.mergeArray(tableLead,systems.mergeArray(accountArray[1],tableTail));
        String sumAmountCr[]=new String[accountArray[0].length],sumAmountDr[]=new String[accountArray[0].length],sumTotalCashCr="0.00",sumTotalCashDr="0.00";
                cellEditable=systems.generateBooleanArrayFalse(tableHeader.length);
        String sumAmtValue[]=new String[accountArray[0].length];
        tableObject=new Object[y+1][tableHeader.length];
        String totRevenue="";
        String totRevenuePrev="";
        while(x<=y)
        {
           if(jMonthComboBox.getSelectedItem().toString().equalsIgnoreCase("-- Month --")==false)
           {
                totRevenue=systems.getTotalRevenueAmount( "'"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 00:00:00'", "'"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 23:59:59'");
                totRevenuePrev=systems.getTotalRevenueAmount("'1920/1/1 00:00:00'", "DATE_SUB('"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 23:59:59',INTERVAL 1 DAY)");
           }else
           {
                totRevenue=systems.getTotalRevenueAmount( "'"+jYearComboBox.getSelectedItem().toString()+"/"+x+"/01 00:00:00'", "'"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/"+systems.getMonthMaximumDay(systems.getMonthName(reportDays[x])) +" 23:59:59'");
                totRevenuePrev=systems.getTotalRevenueAmount("'1920/1/1 00:00:00'", "DATE_SUB('"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/01 23:59:59',INTERVAL 1 DAY)");
           }
            String itemActUnit=systems.getValue(OpenMSApp.Database_A, "Select * from account where cCategory='"+accountType+"'", 5);
            
            if(totRevenue==null||totRevenue.isEmpty())totRevenue="N/A";
            String totalCash="0.00",totalCashDr="0.00";
            String prevCashBalance="";
            
            if(jMonthComboBox.getSelectedItem().toString().equalsIgnoreCase("-- Month --")==false)
            tableObject[x-1][0]=reportDays[x]+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+jYearComboBox.getSelectedItem().toString();
            else
            tableObject[x-1][0]=systems.getMonthName(reportDays[x])+"/"+jYearComboBox.getSelectedItem().toString();
            
            String amount="";
            String amountDr="";
            for(int xa=0;xa<accountArray[0].length;xa++)
            {
                if(sumAmountCr[xa]==null||sumAmountCr[xa].isEmpty())sumAmountCr[xa]="0.00";
                if(sumAmountDr[xa]==null||sumAmountDr[xa].isEmpty())sumAmountDr[xa]="0.00";
                
               if(jMonthComboBox.getSelectedItem().toString().equalsIgnoreCase("-- Month --")==false)
               {
                   amount=systems.getTotalAccountCreditAmount(accountArray[0][xa],"'"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 00:00:00'", "'"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 23:59:59'");
                   if(amount==null||amount.isEmpty())amount="N/A";else sumAmountCr[xa]=systems.getValue(OpenMSApp.Database_A, "Select "+sumAmountCr[xa]+" + "+amount+" AS 'Sum' ", 1);
                   amountDr=systems.getTotalAccountDebitAmount(accountArray[0][xa],"'"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 00:00:00'", "'"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 23:59:59'");
                   if(amountDr==null||amountDr.isEmpty())amountDr="N/A";else sumAmountDr[xa]=systems.getValue(OpenMSApp.Database_A, "Select "+sumAmountDr[xa]+" + "+amountDr+" AS 'Sum' ", 1);
               }
               else
               {
                   amount=systems.getTotalAccountCreditAmount(accountArray[0][xa],"'"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/01 00:00:00'", "'"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/"+systems.getMonthMaximumDay(systems.getMonthName(reportDays[x]))+" 23:59:59'");
                   if(amount==null||amount.isEmpty())amount="N/A";else sumAmountCr[xa]=systems.getValue(OpenMSApp.Database_A, "Select "+sumAmountCr[xa]+" + "+amount+" AS 'Sum' ", 1);
                   amountDr=systems.getTotalAccountDebitAmount(accountArray[0][xa],"'"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/01 00:00:00'", "'"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/"+systems.getMonthMaximumDay(systems.getMonthName(reportDays[x]))+" 23:59:59'");
                   if(amountDr==null||amountDr.isEmpty())amountDr="N/A";else sumAmountDr[xa]=systems.getValue(OpenMSApp.Database_A, "Select "+sumAmountDr[xa]+" + "+amountDr+" AS 'Sum' ", 1);
               }
               tableObject[x-1][xa+1]=amount+" || "+amountDr;
               totalCash=systems.getValue(OpenMSApp.Database_A, Connect.procInit+"  prnAddMoney"+Connect.procInitStart+""+totalCash+" , "+amount+Connect.procInitEnd, "mSumValue");
               totalCashDr=systems.getValue(OpenMSApp.Database_A, Connect.procInit+"  prnAddMoney"+Connect.procInitStart+""+totalCashDr+" , "+amountDr+Connect.procInitEnd, "mSumValue");
                if(sumAmtValue[xa]==null||sumAmtValue[xa].isEmpty())sumAmtValue[xa]="0.00";
               sumAmtValue[xa]=systems.getValue(OpenMSApp.Database_A, Connect.procInit+"  prnAddMoney"+Connect.procInitStart+""+sumAmtValue[xa]+" , "+amount+Connect.procInitEnd, "mSumValue");
            }
            tableObject[x-1][tableHeader.length-2]=totalCash+" || "+totalCashDr;
            tableObject[x-1][tableHeader.length-1]=systems.getValue(OpenMSApp.Database_A, "Select "+totalCash+" - "+totalCashDr+" AS 'Sum' ", 1);
            
            x+=1;
            if(x>y){break;}
       }
        tableObject[x-1][0]="TOTAL";
        for(int xa=0;xa<accountArray[0].length;xa++)
        {
           tableObject[x-1][xa+1]=sumAmountCr[xa]+" || "+sumAmountDr[xa];
           sumTotalCashCr=systems.getValue(OpenMSApp.Database_A, Connect.procInit+"  prnAddMoney"+Connect.procInitStart+""+sumTotalCashCr+" , "+sumAmountCr[xa]+Connect.procInitEnd, "mSumValue");
           sumTotalCashDr=systems.getValue(OpenMSApp.Database_A, Connect.procInit+"  prnAddMoney"+Connect.procInitStart+""+sumTotalCashDr+" , "+sumAmountDr[xa]+Connect.procInitEnd, "mSumValue");
        }
        tableObject[x-1][tableHeader.length-2]=sumTotalCashCr+" || "+sumTotalCashDr;
        tableObject[x-1][tableHeader.length-1]=systems.getValue(OpenMSApp.Database_A, "Select "+sumTotalCashCr+" - "+sumTotalCashDr+" AS 'Sum' ", 1);

        
        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            tableObject,tableHeader
        ) {
            boolean[] canEdit = cellEditable;

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        Connect.closeMainConnection();
        Connect.createMSSQLConnection();
    }
     void print()
    {
        try
        {
            jTable1.print();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
    void refreshTable()
    {
        String[] reportDays={};int y=0;
        if(jMonthComboBox.getSelectedItem().toString().equalsIgnoreCase("-- Month --")==false){
            reportDays=systems.getDays(jMonthComboBox.getSelectedItem().toString());
            y=reportDays.length-1;
        }
        else{
            reportDays=new String[]{"","01","02","03","04","05","06","07","08","09","10","11","12"};
            y=reportDays.length-1;
        }
        
        int x=1;
        System.out.println("Length of report days= "+y);
        String sumTotRevenue="0.00",sumTotExpense="0.00",sumTotHybridCr="0.00",sumTotHybridDr="0.00",sumTotReceivableCr="0.00",sumTotReceivableDr="0.00",sumTotPayableDr="0.00",sumTotPayableCr="0.00";
        String itemActUnit="";
        String cashAvailable="";
        String prevCashBalance="",prevInitCashBalance="";
        tableObject=new Object[y+1][13];
            String totRevenue="";
            String totExpense="";
            String totHybridCr="";
            String totHybridDr="";
            String totReceivableCr="";
            String totReceivableDr="";
            String totPayableCr="";
            String totPayableDr="";

            String totRevenuePrev="";
            String totExpensePrev="";
            String totHybridCrPrev="";
            String totHybridDrPrev="";
            String totReceivableCrPrev="";
            String totReceivableDrPrev="";
            String totPayableCrPrev="";
            String totPayableDrPrev="";
 
        while(x<=y)
        {
            
        if(jMonthComboBox.getSelectedItem().toString().equalsIgnoreCase("-- Month --")==false){
            totRevenue=systems.getTotalRevenueAmount( "'"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 00:00:00'", "'"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 23:59:59'");
            totExpense=systems.getTotalExpenseAmount("'"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 00:00:00'", "'"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 23:59:59'");
            totHybridCr=systems.getTotalHybridCrAmount("'"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 00:00:00'", "'"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 23:59:59'");
            totHybridDr=systems.getTotalHybridDrAmount("'"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 00:00:00'", "'"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 23:59:59'");
            totReceivableCr=systems.getTotalReceivableCrAmount("'"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 00:00:00'", "'"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 23:59:59'");
            totReceivableDr=systems.getTotalReceivableDrAmount("'"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 00:00:00'", "'"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 23:59:59'");
            totPayableCr=systems.getTotalPayableCrAmount("'"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 00:00:00'", "'"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 23:59:59'");
            totPayableDr=systems.getTotalPayableDrAmount("'"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 00:00:00'", "'"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 23:59:59'");

            totRevenuePrev=systems.getTotalRevenueAmount("'1920/1/1 00:00:00'", "DATE_SUB('"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 23:59:59',INTERVAL 1 DAY)");
            totExpensePrev=systems.getTotalExpenseAmount("'1920/1/1 00:00:00'", "DATE_SUB('"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 23:59:59',INTERVAL 1 DAY)");
            totHybridCrPrev=systems.getTotalHybridCrAmount("'1920/1/1 00:00:00'", "DATE_SUB('"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 23:59:59',INTERVAL 1 DAY)");
            totHybridDrPrev=systems.getTotalHybridDrAmount("'1920/1/1 00:00:00'", "DATE_SUB('"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 23:59:59',INTERVAL 1 DAY)");
            totReceivableCrPrev=systems.getTotalReceivableCrAmount("'1920/1/1 00:00:00'", "DATE_SUB('"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 23:59:59',INTERVAL 1 DAY)");
            totReceivableDrPrev=systems.getTotalReceivableDrAmount("'1920/1/1 00:00:00'", "DATE_SUB('"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 23:59:59',INTERVAL 1 DAY)");
            totPayableCrPrev=systems.getTotalPayableCrAmount("'1920/1/1 00:00:00'", "DATE_SUB('"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 23:59:59',INTERVAL 1 DAY)");
            totPayableDrPrev=systems.getTotalPayableDrAmount("'1920/1/1 00:00:00'", "DATE_SUB('"+jYearComboBox.getSelectedItem().toString()+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+x+" 23:59:59',INTERVAL 1 DAY)");
 
        }else{
            totRevenue=systems.getTotalRevenueAmount( "'"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/01 00:00:00'", "'"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/"+systems.getMonthMaximumDay(systems.getMonthName(reportDays[x]))+" 23:59:59'");
            totExpense=systems.getTotalExpenseAmount("'"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/01 00:00:00'", "'"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/"+systems.getMonthMaximumDay(systems.getMonthName(reportDays[x]))+" 23:59:59'");
            totHybridCr=systems.getTotalHybridCrAmount("'"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/01 00:00:00'", "'"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/"+systems.getMonthMaximumDay(systems.getMonthName(reportDays[x]))+" 23:59:59'");
            totHybridDr=systems.getTotalHybridDrAmount("'"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/01 00:00:00'", "'"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/"+systems.getMonthMaximumDay(systems.getMonthName(reportDays[x]))+" 23:59:59'");
            totReceivableCr=systems.getTotalReceivableCrAmount("'"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/01 00:00:00'", "'"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/"+systems.getMonthMaximumDay(systems.getMonthName(reportDays[x]))+" 23:59:59'");
            totReceivableDr=systems.getTotalReceivableDrAmount("'"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/01 00:00:00'", "'"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/"+systems.getMonthMaximumDay(systems.getMonthName(reportDays[x]))+" 23:59:59'");
            totPayableCr=systems.getTotalPayableCrAmount("'"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/01 00:00:00'", "'"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/"+systems.getMonthMaximumDay(systems.getMonthName(reportDays[x]))+" 23:59:59'");
            totPayableDr=systems.getTotalPayableDrAmount("'"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/01 00:00:00'", "'"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/"+systems.getMonthMaximumDay(systems.getMonthName(reportDays[x]))+" 23:59:59'");

            totRevenuePrev=systems.getTotalRevenueAmount("'1920/1/1 00:00:00'", "DATE_SUB('"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/01 23:59:59',INTERVAL 1 DAY)");
            totExpensePrev=systems.getTotalExpenseAmount("'1920/1/1 00:00:00'", "DATE_SUB('"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/01 23:59:59',INTERVAL 1 DAY)");
            totHybridCrPrev=systems.getTotalHybridCrAmount("'1920/1/1 00:00:00'", "DATE_SUB('"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/01 23:59:59',INTERVAL 1 DAY)");
            totHybridDrPrev=systems.getTotalHybridDrAmount("'1920/1/1 00:00:00'", "DATE_SUB('"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/01 23:59:59',INTERVAL 1 DAY)");
            totReceivableCrPrev=systems.getTotalReceivableCrAmount("'1920/1/1 00:00:00'", "DATE_SUB('"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/01 23:59:59',INTERVAL 1 DAY)");
            totReceivableDrPrev=systems.getTotalReceivableDrAmount("'1920/1/1 00:00:00'", "DATE_SUB('"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/01 23:59:59',INTERVAL 1 DAY)");
            totPayableCrPrev=systems.getTotalPayableCrAmount("'1920/1/1 00:00:00'", "DATE_SUB('"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/01 23:59:59',INTERVAL 1 DAY)");
            totPayableDrPrev=systems.getTotalPayableDrAmount("'1920/1/1 00:00:00'", "DATE_SUB('"+jYearComboBox.getSelectedItem().toString()+"/"+reportDays[x]+"/01 23:59:59',INTERVAL 1 DAY)");
  
        }
            itemActUnit=systems.getValue(OpenMSApp.Database_A, "Select * from account where cCategory='REVENUE'", 5);
            
            if(totRevenue==null||totRevenue.isEmpty())totRevenue="N/A";else sumTotRevenue=systems.getValue(OpenMSApp.Database_A, "Select "+sumTotRevenue+" + "+totRevenue+" AS 'Sum' ", 1);
            if(totExpense==null||totExpense.isEmpty())totExpense="N/A";else sumTotExpense=systems.getValue(OpenMSApp.Database_A, "Select "+sumTotExpense+" + "+totExpense+" AS 'Sum' ", 1);
            if(totHybridCr==null||totHybridCr.isEmpty())totHybridCr="N/A";else sumTotHybridCr=systems.getValue(OpenMSApp.Database_A, "Select "+sumTotHybridCr+" + "+totHybridCr+" AS 'Sum' ", 1);
            if(totHybridDr==null||totHybridDr.isEmpty())totHybridDr="N/A";else sumTotHybridDr=systems.getValue(OpenMSApp.Database_A, "Select "+sumTotHybridDr+" + "+totHybridDr+" AS 'Sum' ", 1);
            if(totReceivableCr==null||totReceivableCr.isEmpty())totReceivableCr="N/A";else sumTotReceivableCr=systems.getValue(OpenMSApp.Database_A, "Select "+sumTotReceivableCr+" + "+totReceivableCr+" AS 'Sum' ", 1);
            if(totReceivableDr==null||totReceivableDr.isEmpty())totReceivableDr="N/A";else sumTotReceivableDr=systems.getValue(OpenMSApp.Database_A, "Select "+sumTotReceivableDr+" + "+totReceivableDr+" AS 'Sum' ", 1);
            if(totPayableCr==null||totPayableCr.isEmpty())totPayableCr="N/A";else sumTotPayableCr=systems.getValue(OpenMSApp.Database_A, "Select "+sumTotPayableCr+" + "+totPayableCr+" AS 'Sum' ", 1);
            if(totPayableDr==null||totPayableDr.isEmpty())totPayableDr="N/A";else sumTotPayableDr=systems.getValue(OpenMSApp.Database_A, "Select "+sumTotPayableDr+" + "+totPayableDr+" AS 'Sum' ", 1);
            
            if(jMonthComboBox.getSelectedItem().toString().equalsIgnoreCase("-- Month --")==false)
            tableObject[x-1][0]=reportDays[x]+"/"+systems.getMonthDigit(jMonthComboBox.getSelectedItem().toString())+"/"+jYearComboBox.getSelectedItem().toString();
            else
            tableObject[x-1][0]=systems.getMonthName(reportDays[x])+"/"+jYearComboBox.getSelectedItem().toString();
            tableObject[x-1][1]=totRevenue;
            tableObject[x-1][2]=totExpense;
            tableObject[x-1][3]=totHybridCr;
            tableObject[x-1][4]=totHybridDr;
            tableObject[x-1][5]=totReceivableCr;
            tableObject[x-1][6]=totReceivableDr;
            tableObject[x-1][7]=totPayableCr;
            tableObject[x-1][8]=totPayableDr;
            tableObject[x-1][9]=cashAvailable=systems.getValue(OpenMSApp.Database_A, "Select ("+totRevenue+" + "+totPayableCr+"+"+totReceivableCr+" + "+totHybridCr+") - ("+totExpense+"+"+totPayableDr+"+"+totHybridDr+"+"+totReceivableDr+") AS 'Sum' ", 1);
            tableObject[x-1][10]=prevCashBalance=systems.getValue(OpenMSApp.Database_A, "Select ("+totRevenuePrev+" + "+totPayableCrPrev+"+"+totReceivableCrPrev+" + "+totHybridCrPrev+") - ("+totExpensePrev+"+"+totPayableDrPrev+"+"+totHybridDrPrev+"+"+totReceivableDrPrev+") AS 'Sum' ", 1);
            tableObject[x-1][11]=systems.getValue(OpenMSApp.Database_A, "Select "+cashAvailable+" + "+prevCashBalance+" AS 'Sum' ", 1);
            tableObject[x-1][12]=itemActUnit;
            if(x==1)prevInitCashBalance=prevCashBalance;
//            Connect.closeMainConnection();
//            Connect.createMSSQLConnection();
            systems.freeHeap();
            x+=1;
            if(x>y){break;}
       }
            tableObject[x-1][0]="Total";
            tableObject[x-1][1]=sumTotRevenue;
            tableObject[x-1][2]=sumTotExpense;
            tableObject[x-1][3]=sumTotHybridCr;
            tableObject[x-1][4]=sumTotHybridDr;
            tableObject[x-1][5]=sumTotReceivableCr;
            tableObject[x-1][6]=sumTotReceivableDr;
            tableObject[x-1][7]=sumTotPayableCr;
            tableObject[x-1][8]=sumTotPayableDr;
            tableObject[x-1][9]=cashAvailable=systems.getValue(OpenMSApp.Database_A, "Select ("+sumTotRevenue+" + "+sumTotPayableCr+"+"+sumTotReceivableCr+" + "+sumTotHybridCr+") - ("+sumTotExpense+"+"+sumTotPayableDr+"+"+sumTotHybridDr+"+"+sumTotReceivableDr+") AS 'Sum' ", 1);
            tableObject[x-1][10]=prevInitCashBalance;
            tableObject[x-1][11]=systems.getValue(OpenMSApp.Database_A, "Select "+cashAvailable+" + "+prevInitCashBalance+" AS 'Sum' ", 1);
            tableObject[x-1][12]=itemActUnit;
            
        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            tableObject,
            new String [] {
                "Date", "Revenue", "Expense", "Hybrid (Cr)", "Hybrid (Dr)", "Receivable (Cr)", "Receivable (Dr)", "Payable (Cr)", "Payable (Dr)", "Cash Available", "Previous Cash Balance", "Cash Balance", "Unit"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox jAccountTypeComboBox;
    private javax.swing.JButton jCancelButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JComboBox jMonthComboBox;
    private javax.swing.JButton jRefreshButton;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JComboBox jYearComboBox;
    // End of variables declaration//GEN-END:variables

}
